package com.zx.zxblog.controller;

import com.zx.zxblog.entity.enums.SysConfigEnum;
import com.zx.zxblog.entity.pojo.Blog;
import com.zx.zxblog.mapper.BlogMapper;
import com.zx.zxblog.service.BlogService;
import com.zx.zxblog.service.SysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

/**
 * className=ArticleController
 * package=com.zx.zxblog.controller
 * description:
 *
 * @Author:SKEZhi
 * @Create:2024/4/4 - 23:43
 * @Version: v1.0
 */
@Controller
public class ArticleController {

    @Autowired
    private BlogMapper blogMapper;
    @Autowired
    private BlogService blogService;

    @Autowired
    private SysConfigService sysConfigService;
    @GetMapping("/article")
    public String article(Model model){
//        List<Blog> blogList = blogMapper.selectList(null);
        List<Blog> blogList = blogService.getBlogListDesc();
        // 获取作者
        String author = sysConfigService.getByEnums(SysConfigEnum.AUTHOR).getValue();
        model.addAttribute("blogList", blogList);
        model.addAttribute("author",author);
        return "article";
    }
}
